//
//  TTRecyclingCellTopView.m
//  TaoTuo
//
//  Created by zhaoshijie on 2020/8/31.
//  Copyright © 2020 刘广. All rights reserved.
//

#import "TTRecyclingCellTopView.h"

@interface TTRecyclingCellTopView ()

@property (nonatomic, strong) UIButton *leftBtn;
@property (nonatomic, strong) UIButton *rightImageBtn;
@property (nonatomic, strong) UIView *lineView;

@end

@implementation TTRecyclingCellTopView

- (instancetype)init
{
    self = [super init];
    if (self) {
        
        [self rightImageBtn];
        [self lineView];
        
    }
    return self;
}

/// 点击了右侧箭头按钮
- (void)lookDetailAction
{
//    [LLRouteTool getCurrentNavigationController] pushViewController:<#(nonnull UIViewController *)#> animated:<#(BOOL)#>;
}

- (void)setHiddenRightArrow:(BOOL)hiddenRightArrow
{
    _hiddenRightArrow = hiddenRightArrow;
    self.rightImageBtn.hidden = _hiddenRightArrow;
}

- (void)setImageName:(NSString *)imageName title:(NSString *)title
{
    NSString *t = [NSString stringWithFormat:@"  %@", title];
    [self.leftBtn setTitle:t forState:UIControlStateNormal];
    [self.leftBtn setImage:[UIImage imageNamed:imageName] forState:UIControlStateNormal];

    [self rightImageBtn];
    [self lineView];
}

- (UIButton *)leftBtn
{
    if (!_leftBtn) {
        _leftBtn = [UIButton createButtonWithTitle:@"" titleColor:UIColorHex(333333) titleFont:[UIFont systemFontOfSize:12] backgroundColor:nil target:nil action:nil];
        [self addSubview:_leftBtn];
        [_leftBtn mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(@10);
            make.centerY.equalTo(self);
        }];
    }
    return _leftBtn;
}

- (UIButton *)rightImageBtn
{
    if (!_rightImageBtn) {
        _rightImageBtn = [UIButton createButtonWithImage:[UIImage imageNamed:@"cellarrow_4"] target:self action:@selector(lookDetailAction)];
        [self addSubview:_rightImageBtn];
        [_rightImageBtn mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.bottom.right.equalTo(self);
            make.width.mas_equalTo(40);
        }];
    }
    return _rightImageBtn;
}

- (UIView *)lineView
{
    if (!_lineView) {
        _lineView = [[UIView alloc] init];
        _lineView.backgroundColor = UIColorHex(F7F7F7);
        [self addSubview:_lineView];
        [_lineView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.right.bottom.equalTo(self);
            make.height.equalTo(@1);
        }];
    }
    return _lineView;
}

@end
